class Solution
{
public:
    int minSkips(vector<int> &dist, int speed, int hoursBefore)
    {
        int n = dist.size();
        vector<vector<double>> dp(n, vector<double>(n + 1, 1e18));

        double eps = 1e-7;
        auto t = [&](double d)
        {
            return d / speed - eps;
        };

        dp[0][0] = ceil(t(dist[0]));
        dp[0][1] = t(dist[0]);
        for (int i = 1; i < n; ++i)
        {
            for (int skip = 0; skip <= i + 1; ++skip)
            {

                dp[i][skip] = min(dp[i][skip], ceil(dp[i - 1][skip] + t(dist[i])));
                if (skip > 0)
                {
                    dp[i][skip] = min(dp[i][skip], dp[i - 1][skip - 1] + t(dist[i]));
                }
            }
        }

        for (int skip = 0; skip <= n; ++skip)
        {
            if (dp[n - 1][skip] <= hoursBefore + eps)
            {
                return skip;
            }
        }

        return -1;
    }
};